/* exec.c
 *      Test program for the exec statement in nachos
 */
#include "syscall.h"

int main() {

    char fname[] = "exec_args";
    char arg[] = "1";
    char* args[2] = {arg, 0};

    int status;
    int child_id;

    if((void*)args == (void*)arg) {
        Exit(3);
    }

    child_id = Exec(fname, args);

    //if the exec call failed, then return an exit code to be able to tell
    //it failed
    if(child_id == -1) {
        Exit(2);
    }

    status = Join(child_id);
    if(status == 0) {
        //we had a success
        Exit(0);
    } else {
        Exit(status);
    }

}
